package com.ygxsk.carhome.ui.repair;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.ClickUtils;
import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.flyco.roundview.RoundTextView;
import com.gyf.immersionbar.ImmersionBar;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.tencent.mmkv.MMKV;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.constant.ConstantApi;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.constant.ExtraKey;
import com.ygxsk.carhome.constant.ExtraValue;
import com.ygxsk.carhome.enumwrap.CallHistoryBusinessType;
import com.ygxsk.carhome.enumwrap.RepairStateType;
import com.ygxsk.carhome.enumwrap.RepairStatusUpLoadType;
import com.ygxsk.carhome.listener.Delivery;
import com.ygxsk.carhome.response.RepairManageItemBean;
import com.ygxsk.carhome.response.RepairManageItemOutSide;
import com.ygxsk.carhome.retrofit.AddLogUpLoadInfo;
import com.ygxsk.carhome.retrofit.ApiException;
import com.ygxsk.carhome.retrofit.ApiRequestSubListener;
import com.ygxsk.carhome.retrofit.ApiService;
import com.ygxsk.carhome.retrofit.ErrorConsumer;
import com.ygxsk.carhome.retrofit.NetworkManager;
import com.ygxsk.carhome.retrofit.ResponseTransformer;
import com.ygxsk.carhome.sys.Session;
import com.ygxsk.carhome.ui.ErrorActivity;
import com.ygxsk.carhome.ui.adapter.RepairHistoryListAdapter;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.DateUtilFir;
import com.ygxsk.carhome.utils.ViewUitls;
import com.ygxsk.carhome.views.ClearEditTextUser;
import com.ygxsk.carhome.views.MyLinearLayoutManager;
import com.ygxsk.carhome.views.picker.NomalCustomBean;
import com.ygxsk.carhome.views.picker.NomalPickerDialogFragment;
import com.ygxsk.carhome.views.picker.YearMonthDayDialogFragment;
import com.ygxsk.carhome.views.spinner.NiceSpinnersk;
import com.ygxsk.integrated.retrofit.Parameterkey;

import java.util.ArrayList;
import java.util.HashMap;

import butterknife.BindView;
import butterknife.internal.DebouncingOnClickListener;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-07-18  15:04
 * @Description:预约维保的界面内容,预约维保的记录
 */
public class RepairHistoryActivity extends ErrorActivity {

    @BindView(R.id.refreshlayoutinrepairmanagelisthistory)
    SmartRefreshLayout refreshLayoutInRepairManageListHistory;

    @BindView(R.id.recyclerviewinrepairlisthistory)
    RecyclerView recyclerViewInRepairListHistory;

    //搜索框逻辑 携带叉号
    @BindView(R.id.et_searchinmanagecheckrecordhis)
    ClearEditTextUser et_searchInManageCheckRecord;

    //搜索文字 按钮内容
    @BindView(R.id.textviewsearchinmanagecheckrecordhis)
    TextView textViewSearchInManageCheckRecord;

    //筛选条件的 是汽车的状态
    private ArrayList<NomalCustomBean> dataLisRepairStatusType = new ArrayList<>();

    //选择 是分配状态的筛选 状态
    @BindView(R.id.nice_spinner_status_item_repair_his)
    NiceSpinnersk nice_spinner_status_item_repair;

    //选择开始日期
    @BindView(R.id.nice_spinner_start_date_his)
    NiceSpinnersk nice_spinner_start_date;

    //选择结束日期
    @BindView(R.id.nice_spinner_end_date_his)
    NiceSpinnersk nice_spinner_end_date;

    //右侧的搜索-查询 按钮
    @BindView(R.id.roundtextviewrepairsearchrighthis)
    RoundTextView roundTextViewRepairSearchRight;

    //右侧的 全部重置 按钮
    @BindView(R.id.roundtextviewrepairesetrighthis)
    RoundTextView roundTextViewRepaiResetRight;

    //筛选的开始时间
    private String spinner_startTime_upLoad = "";
    //筛选的结束时间
    private String spinner_endTime_upLoad = "";

    //筛选的开始时间展示
    private ArrayList<String> dataStartTime = new ArrayList<>();
    //筛选的结束时间展示
    private ArrayList<String> dataEndTime = new ArrayList<>();

    //传递的状态值内容 0, "待处理"  1, "已分配"  2, "已接单"  3, "已确认" 4, "已完成" 5, "已取消"
    private String status_upLoad = "";

    //传递输入的关键字信息
    private String keyWord_upLoad = "";

    //分配客户人员
//    @BindView(R.id.roundbuttonaddreapirmanagemangroup)
//    RoundTextView roundButtonAddReapirManageanGroup;

    //选择类型
//    @BindView(R.id.nice_spinner_type_repair_history)
//    NiceSpinnersk nice_spinner_type_repair_history;

    //选择来源
//    @BindView(R.id.nice_spinner_formwhere)
//    NiceSpinnersk nice_spinner_formWhere;

    //选择状态
//    @BindView(R.id.nice_spinner_state_item_repair_history)
//    NiceSpinnersk nice_spinner_state_item_repair_history;


    //潜在客户，
    private ArrayList<RepairManageItemBean> mDataResources = new ArrayList<>();

    //筛选条件的 汽车的类型； 是预约保养，还是预约维修；
//    private ArrayList<NomalCustomBean> dataLisRepairType = new ArrayList<>();
    //客户的来源
//    private ArrayList<NomalCustomBean> dataListFromWhere = new ArrayList();
    //该客户的分配状态
//    private ArrayList<NomalCustomBean> dataListStateItem = new ArrayList<>();

    //维保管理的适配器
    private RepairHistoryListAdapter repairHistoryListAdapter;

    /**
     * 最后一条上传的id的信息内容
     */
    private int pagination_upLoad = Parameterkey.pageNum_default_first;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mActivityInstance = this;

        mSession = Session.get(this);


        if (dataLisRepairStatusType == null) {
            dataLisRepairStatusType = new ArrayList<>();
        }

//        if (dataLisRepairType == null) {
//            dataLisRepairType = new ArrayList<>();
//        }

//        if (dataListFromWhere == null) {
//            dataListFromWhere = new ArrayList<>();
//        }

//        if (dataListStateItem == null) {
//            dataListStateItem = new ArrayList<>();
//        }

        initloading();

        initViews();

        gainDatas();

        //其他的类似 监听器的，提交一个客户

        //监听单个客户内容
        //列表之内需要向外部广播数据
//        if (!EventBus.getDefault().isRegistered(this)) {
//            EventBus.getDefault().register(this);
//        }


    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_repair_history;
    }

    @Override
    protected void initToolBar(ToolbarHelper toolbarHelper) {

        toolbarHelper.setTitle(getString(R.string.title_repair_manager_history));
        toolbarHelper.setVersionName(true, AppUtils.getAppVersionName());
        toolbarHelper.setLayoutClose(false, "", null);
        toolbarHelper.setLayoutLeft(true, R.drawable.backicon, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //搜索客户信息，优先关闭软键盘
                KeyboardUtils.hideSoftInput(mActivityInstance);
                methodBack();
            }
        });

        //这里右上角没有东西的
        toolbarHelper.setLayoutRight(true, 0, "", null);

        //添加潜在客户的按钮
//        toolbarHelper.setLayoutRight(true, 0, "添加", new ClickUtils.OnDebouncingClickListener() {
//            @Override
//            public void onDebouncingClick(View v) {
//
//                //快速双加的限制，
//                // : 2023-07-11 16:18 添加预约维保的信息，到提交表单页面；
//                Bundle extra_bundle = new Bundle();
////                ActivityUtils.startActivity(extra_bundle, LeadAddSubmitActivity.class);
//            }
//        });

    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();

        ImmersionBar.with(this)//
                .titleBar(R.id.toolbarygxskout)
                .fitsSystemWindows(true)//解决状态栏和布局重叠问题，任选其一，默认为false，当为true时一定要指定statusBarColor()，不然状态栏为透明色，还有一些重载方法
                //.statusBarColor(R.color.colorPrimary)//
                //.navigationBarColor(R.color.colorPrimary)//
                //.keyboardEnable(true)
                .init();

    }

    @Override
    protected void onClickNodata(View v) {

        gainDatas();

    }

    @Override

    protected void initViews() {

        // : 2023-07-13 15:55 假数据
//        RepairManageItemBean repairManageItemBean = new RepairManageItemBean();
//        repairManageItemBean.setItemState("已分配");
//        repairManageItemBean.setCarNumber("北1254");
//        repairManageItemBean.setPersonName("陈大");
//        repairManageItemBean.setPersonPhone("17531108969");
//        repairManageItemBean.setTypeRepair("新车");
//
//        RepairManageItemBean repairManageItemBean1 = new RepairManageItemBean();
//        repairManageItemBean1.setItemState("已确认");
//        repairManageItemBean1.setCarNumber("北1254");
//        repairManageItemBean1.setPersonName("陈大");
//        repairManageItemBean1.setPersonPhone("18810042043");
//        repairManageItemBean1.setTypeRepair("二手车");
//
//        RepairManageItemBean repairManageItemBean2 = new RepairManageItemBean();
//        repairManageItemBean2.setItemState("战败");
//        repairManageItemBean2.setPersonName("陈大");
//        repairManageItemBean2.setCarNumber("北1254");
//        repairManageItemBean2.setPersonPhone("17531108968");
//        repairManageItemBean2.setTypeRepair("二手车");
//
//        mDataResources.add(repairManageItemBean);
//        mDataResources.add(repairManageItemBean1);
//        mDataResources.add(repairManageItemBean2);

        //----------------------------------------------------------------------------------
//        // : 2023-07-14 09:23 测试类型数据
//        NomalCustomBean nomalCustomBean = new NomalCustomBean();
//        nomalCustomBean.setDictCode("1");
//        nomalCustomBean.setDictLabel("预约维修");
//
//        NomalCustomBean nomalCustomBean1 = new NomalCustomBean();
//        nomalCustomBean1.setDictCode("2");
//        nomalCustomBean1.setDictLabel("预约保养");
//
//        dataLisRepairType.add(nomalCustomBean);
//        dataLisRepairType.add(nomalCustomBean1);
//
//        //直接存储mmkv的信息
//        MMKV.defaultMMKV().encode(ConstantSign.MMKV_JSON_NOMAL_CUSTOM_JSON, JSON.toJSONString(dataLisRepairType));
//
//        //初始化 选择类型
//        method_spinnser_type_repair();

        //----------------------------------------------------------------------------------
//        LeadFromWhereBean leadFromWhereBean = new LeadFromWhereBean();
//        leadFromWhereBean.setDictType("1");
//        leadFromWhereBean.setDictLabel("预约看车");
//
//        LeadFromWhereBean leadFromWhereBean1 = new LeadFromWhereBean();
//        leadFromWhereBean1.setDictType("2");
//        leadFromWhereBean1.setDictLabel("预约试驾");
//
//        LeadFromWhereBean leadFromWhereBean2 = new LeadFromWhereBean();
//        leadFromWhereBean2.setDictType("3");
//        leadFromWhereBean2.setDictLabel("自然到店");
//        LeadFromWhereBean leadFromWhereBean3 = new LeadFromWhereBean();
//        leadFromWhereBean3.setDictType("4");
//        leadFromWhereBean3.setDictLabel("服务站推荐");
//        dataListFromWhere.add(leadFromWhereBean);
//        dataListFromWhere.add(leadFromWhereBean1);
//        dataListFromWhere.add(leadFromWhereBean2);
//        dataListFromWhere.add(leadFromWhereBean3);
//        //直接存储mmkv的信息
//        MMKV.defaultMMKV().encode(ConstantSign.MMKV_JSON_FROM_WHERE_JSON, JSON.toJSONString(dataListFromWhere));
//        method_spinnser_formWhere();

        //----------------------------------------------------------------------------------
        // : 2023-07-19 14:59 这里记得一定要做转换
//        NomalCustomBean nomalCustomBeanState = new NomalCustomBean();
//        nomalCustomBeanState.setDictCode("1");
//        nomalCustomBeanState.setDictLabel("已确认");
//
//        NomalCustomBean nomalCustomBeanState1 = new NomalCustomBean();
//        nomalCustomBeanState1.setDictCode("2");
//        nomalCustomBeanState1.setDictLabel("已改约");
//
//        NomalCustomBean nomalCustomBeanState3 = new NomalCustomBean();
//        nomalCustomBeanState3.setDictCode("3");
//        nomalCustomBeanState3.setDictLabel("已取消");
//
//        dataListStateItem.add(nomalCustomBeanState);
//        dataListStateItem.add(nomalCustomBeanState1);
//        dataListStateItem.add(nomalCustomBeanState3);
//
//        //直接存储mmkv的信息
//        MMKV.defaultMMKV().encode(ConstantSign.MMKV_JSON_NOMAL_CUSTOM_JSON, JSON.toJSONString(dataListStateItem));
//
//        method_spinnser_stateItem();

        //----------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------

        if (et_searchInManageCheckRecord != null) {
            et_searchInManageCheckRecord.setHint(getString(R.string.search_keyword_car_repair));
            et_searchInManageCheckRecord.clearFocus();
        }

        //软键盘的【搜索】
        et_searchInManageCheckRecord.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {

                if (actionId == EditorInfo.IME_ACTION_SEARCH || (keyEvent != null && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {

                    //关闭软键盘
                    KeyboardUtils.hideSoftInput(RepairHistoryActivity.this);

                    method_SearchSomeThing();

                    return true;
                }

                return false;
            }
        });

        if (textViewSearchInManageCheckRecord != null) {

            textViewSearchInManageCheckRecord.setOnClickListener(new DebouncingOnClickListener() {
                @Override
                public void doClick(View v) {

                    if (KeyboardUtils.isSoftInputVisible(RepairHistoryActivity.this)) {
                        KeyboardUtils.hideSoftInput(RepairHistoryActivity.this);
                    }

                    method_SearchSomeThing();

                }
            });

        }


        //----------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------
        //2023-10-21 15:47:57 新确认的枚举信息
//        0, "待处理"
//        1, "已分配"
//        2, "已接单"
//        3, "已确认"
//        4, "已完成"
//        5, "已取消"

//        NomalCustomBean nomalCustomBeanState = new NomalCustomBean();
//        nomalCustomBeanState.setDictCode("0");
//        nomalCustomBeanState.setDictLabel("待处理");
//        public enum RepairStateType {
//                STATE_PENDING_HANDLER("0", "待处理"),
//                STATE_HAS_DISPATCH("1", "已分配"),
//                STATE_HAS_RECEIVED("2", "已接单"),
//                STATE_HAS_CONFIRMED("3", "已确认"),
//                STATE_HAS_COMPLETED("4", "已完成"),
//                STATE_HAS_CANCELED("5", "已取消");

        NomalCustomBean nomalCustomBeanStateAll = new NomalCustomBean();
        nomalCustomBeanStateAll.setDictCode(RepairStateType.STATE_ALL.getIndex());
        nomalCustomBeanStateAll.setDictLabel(RepairStateType.STATE_ALL.getValue());

//        NomalCustomBean nomalCustomBeanState = new NomalCustomBean();
//        nomalCustomBeanState.setDictCode(RepairStateType.STATE_PENDING_HANDLER.getIndex());
//        nomalCustomBeanState.setDictLabel(RepairStateType.STATE_PENDING_HANDLER.getValue());

//        NomalCustomBean nomalCustomBeanState1 = new NomalCustomBean();
//        nomalCustomBeanState1.setDictCode(RepairStateType.STATE_HAS_DISPATCH.getIndex());
//        nomalCustomBeanState1.setDictLabel(RepairStateType.STATE_HAS_DISPATCH.getValue());

//        NomalCustomBean nomalCustomBeanState2 = new NomalCustomBean();
//        nomalCustomBeanState2.setDictCode(RepairStateType.STATE_HAS_RECEIVED.getIndex());
//        nomalCustomBeanState2.setDictLabel(RepairStateType.STATE_HAS_RECEIVED.getValue());

//        NomalCustomBean nomalCustomBeanState3 = new NomalCustomBean();
//        nomalCustomBeanState3.setDictCode(RepairStateType.STATE_HAS_CONFIRMED.getIndex());
//        nomalCustomBeanState3.setDictLabel(RepairStateType.STATE_HAS_CONFIRMED.getValue());

        NomalCustomBean nomalCustomBeanState4 = new NomalCustomBean();
        nomalCustomBeanState4.setDictCode(RepairStateType.STATE_HAS_COMPLETED.getIndex());
        nomalCustomBeanState4.setDictLabel(RepairStateType.STATE_HAS_COMPLETED.getValue());

        NomalCustomBean nomalCustomBeanState5 = new NomalCustomBean();
        nomalCustomBeanState5.setDictCode(RepairStateType.STATE_HAS_CANCELED.getIndex());
        nomalCustomBeanState5.setDictLabel(RepairStateType.STATE_HAS_CANCELED.getValue());

        dataLisRepairStatusType.add(nomalCustomBeanStateAll);
//        dataLisRepairStatusType.add(nomalCustomBeanState);
//        dataLisRepairStatusType.add(nomalCustomBeanState1);
//        dataLisRepairStatusType.add(nomalCustomBeanState2);
//        dataLisRepairStatusType.add(nomalCustomBeanState3);
        dataLisRepairStatusType.add(nomalCustomBeanState4);
        dataLisRepairStatusType.add(nomalCustomBeanState5);

        //直接存储mmkv的信息
        MMKV.defaultMMKV().encode(ConstantSign.MMKV_JSON_NOMAL_CUSTOM_JSON_REPAIR_MANAGE_LIST, JSON.toJSONString(dataLisRepairStatusType));

        method_spinnser_stateItem();

        //----------------------------------------------------------------------------------
        method_spinner_startTime_firstCreate();

        //仅仅只有点击能力；
        nice_spinner_start_date.setOnClickListener(new DebouncingOnClickListener() {
            @Override
            public void doClick(View v) {

                YearMonthDayDialogFragment datePickerDialogFragment = YearMonthDayDialogFragment.newInstance(0);

                datePickerDialogFragment.setOnYearMonthDayChooseListener(new YearMonthDayDialogFragment.OnYearMonthDayChooseListener() {

                    @Override
                    public void onYearMonthDayChoose(int year, int month, int day) {

                        if (year > 0 && month > 0 && day > 0) {
                            //选择年月日的内容
                            LogUtils.d("itchen--WorkOrderStatisticsActivity--选中的时间-->" + year + "---" + month + "---" + day);

                            //添加的搜索时间是："createTime":"2023-03-30"
                            spinner_startTime_upLoad = year + "-" + String.format("%02d", month) + "-" + String.format("%02d", day);
                            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "选中的时间--上传时间-->" + spinner_startTime_upLoad);

                            if (!TextUtils.isEmpty(spinner_startTime_upLoad) && !TextUtils.isEmpty(spinner_endTime_upLoad)) {

                                //如果选中的 开始时间 大于 结束时间 是无法通过的;
                                //【开始时间】不能比【完成期限】更靠后:即是：如果【开始时间-大于 完成时间，】那么弹窗提示，返回执行；
                                boolean compareTime = DateUtilFir.comparTwoTime(spinner_startTime_upLoad, spinner_endTime_upLoad);

                                if (compareTime) {
                                    CommUtils.checkDialog(mAlertView);
                                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.repair_bystarttime_comparetime), true);
                                    mAlertView.show();
                                    return;
                                }

                            }

                            Delivery.getInstance().post(new Runnable() {
                                @Override
                                public void run() {
                                    //if (textviewTimeCurSelect != null) {
                                    //   textviewTimeCurSelect.setText(textLastTimeString);
                                    //}
                                    if (dataStartTime != null) {
                                        dataStartTime.clear();
                                        dataStartTime.add(0, spinner_startTime_upLoad);
                                        method_spinner_startTime_select();
                                    }
                                }
                            });

                            // 选中开始时间 还不执行调用接口，等选择完毕结束时间才可以；
//                            //立即调用接口刷新
//                            keyWord_upLoad = et_searchInCustomSmall.getText().toString().trim();
//                            //页码重置
////                            pageNum_upLoad = Parameterkey.pageNum_default_first;
//
//                            if (mDataResources != null && !mDataResources.isEmpty()) {
//                                mDataResources.clear();
//                            }
//
//                            if (repairManageListAdapter != null) {
//                                repairManageListAdapter.notifyDataSetChanged();
//                            }
//
//                            getServerDatas();

                        } else {

                            //选中的是【重置清空】
                            //搜索关键字报错不变

                            //这是选择全部的，清空时间关键字，因为后边有查询按钮，那么这个重置只能改变数值内容暂不调用接口；
                            spinner_startTime_upLoad = "";

                            method_spinner_startTime_firstCreate();

//                            keyWord_upLoad = et_searchInManageCheckRecord.getText().toString().trim();
                            //页码重置
//                            pageNum_upLoad = Parameterkey.pageNum_default_first;

                            //这是要清空数据列表的
//                            if (mDataResources != null && !mDataResources.isEmpty()) {
//                                mDataResources.clear();
//                            }
//
//                            if (repairManageListAdapter != null) {
//                                repairManageListAdapter.notifyDataSetChanged();
//                            }
//
//                            getServerDatas();

                        }
                    }
                });

                datePickerDialogFragment.show(getSupportFragmentManager(), "CheckDatePickerStartDialogFragment");

            }
        });

        //-------------------------------------------------------------------------------------------------------------------------------

        method_spinner_endTime_firstCreate();

        nice_spinner_end_date.setOnClickListener(new DebouncingOnClickListener() {
            @Override
            public void doClick(View v) {

                YearMonthDayDialogFragment datePickerDialogFragment = YearMonthDayDialogFragment.newInstance(0);

                datePickerDialogFragment.setOnYearMonthDayChooseListener(new YearMonthDayDialogFragment.OnYearMonthDayChooseListener() {

                    @Override
                    public void onYearMonthDayChoose(int year, int month, int day) {

                        if (year > 0 && month > 0 && day > 0) {
                            //选择年月日的内容
                            //LogUtils.d("itchen--WorkOrderStatisticsActivity--选中的时间-->" + year + "---" + month + "---" + day);
                            //添加的搜索时间是："createTime":"2023-03-30"
                            spinner_endTime_upLoad = year + "-" + String.format("%02d", month) + "-" + String.format("%02d", day);
                            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "选中的时间--上传时间-->" + spinner_endTime_upLoad);

                            if (!TextUtils.isEmpty(spinner_startTime_upLoad) && !TextUtils.isEmpty(spinner_endTime_upLoad)) {

                                //如果选中的结束时间 小于 开始时间 是无法通过的;
                                //【开始时间】不能比【完成期限】更靠后:即是：如果【开始时间-大于完成时间，】那么弹窗提示，返回执行；
                                boolean compareTime = DateUtilFir.comparTwoTime(spinner_startTime_upLoad, spinner_endTime_upLoad);

                                if (compareTime) {
                                    CommUtils.checkDialog(mAlertView);
                                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.repair_byendtime_comparetime), true);
                                    mAlertView.show();
                                    return;
                                }

                            }

                            Delivery.getInstance().post(new Runnable() {
                                @Override
                                public void run() {

                                    //if (textviewTimeCurSelect != null) {
                                    //   textviewTimeCurSelect.setText(textLastTimeString);
                                    //}

                                    if (dataEndTime != null) {
                                        dataEndTime.clear();
                                        dataEndTime.add(0, spinner_endTime_upLoad);
                                        method_spinner_endTime_select();
                                    }
                                }
                            });

//                            //立即调用接口刷新
//                            keyWord_upLoad = et_searchInCustomSmall.getText().toString().trim();
//                            //页码重置
////                            pageNum_upLoad = Parameterkey.pageNum_default_first;
//
//                            if (mDataResources != null && !mDataResources.isEmpty()) {
//                                mDataResources.clear();
//                            }
//
//                            if (repairManageListAdapter != null) {
//                                repairManageListAdapter.notifyDataSetChanged();
//                            }
//
//                            getServerDatas();

                        } else {//选中的是【重置清空】

                            //搜索关键字报错不变

                            //这是选择全部的，清空时间关键字，不能触发接口，因为是时间段选择
                            spinner_endTime_upLoad = "";
                            method_spinner_endTime_firstCreate();

//                            keyWord_upLoad = et_searchInManageCheckRecord.getText().toString().trim();
//                            //页码重置
////                            pageNum_upLoad = Parameterkey.pageNum_default_first;
//
//                            //这是要清空数据列表的
//                            if (mDataResources != null && !mDataResources.isEmpty()) {
//                                mDataResources.clear();
//                            }
//
//                            if (repairManageListAdapter != null) {
//                                repairManageListAdapter.notifyDataSetChanged();
//                            }
//
//                            getServerDatas();

                        }
                    }
                });

                datePickerDialogFragment.show(getSupportFragmentManager(), "CheckDatePickerEndDialogFragment");

            }
        });


        //----------------------------------------------------------------------------------

        //----------------------------------------------------------------------------------
        //按照时间搜索按钮的点击事件，开始时间和结束时间，如果选择了【开始时间】那么一定要选择【结束时间】
        if (roundTextViewRepairSearchRight != null) {
            roundTextViewRepairSearchRight.setOnClickListener(new DebouncingOnClickListener() {
                @Override
                public void doClick(View v) {

                    //2023-10-25 17:52:38 发现软键盘遮挡
                    KeyboardUtils.hideSoftInput(RepairHistoryActivity.this);

                    if (!TextUtils.isEmpty(spinner_startTime_upLoad) && TextUtils.isEmpty(spinner_endTime_upLoad)) {
                        //如果选中了开始时间，没有选中结束时间；
                        //那么提示【请选择结束时间】
                        //选择时间异常，请重新选择；
                        CommUtils.checkDialog(mAlertView);
                        mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.repair_endtime_isnull), true);
                        mAlertView.show();
                        return;

                    }

                    if (TextUtils.isEmpty(spinner_startTime_upLoad) && !TextUtils.isEmpty(spinner_endTime_upLoad)) {
                        //如果选中了结束时间，没有选中开始时间；
                        //那么提示【请选择开始时间】
                        //选择时间异常，请重新选择；
                        CommUtils.checkDialog(mAlertView);
                        mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.repair_starttime_isnull), true);
                        mAlertView.show();
                        return;

                    }

                    // 选中开始时间 还不执行调用接口，等选择完毕结束时间才可以；
                    //立即调用接口刷新
                    keyWord_upLoad = et_searchInManageCheckRecord.getText().toString().trim();

                    //发起重新 查询条件 要重置为 从第一页查询,必须重置；
                    pagination_upLoad = Parameterkey.pageNum_default_first;

                    if (mDataResources != null && !mDataResources.isEmpty()) {
                        mDataResources.clear();
                    }

                    if (repairHistoryListAdapter != null) {
                        repairHistoryListAdapter.notifyDataSetChanged();
                    }

                    getServerDatas();

                }
            });
        }

        //按钮的点击事件
        if (roundTextViewRepaiResetRight != null) {
            roundTextViewRepaiResetRight.setOnClickListener(new DebouncingOnClickListener() {
                @Override
                public void doClick(View v) {

                    //2023-10-25 17:52:38 发现软键盘遮挡
                    KeyboardUtils.hideSoftInput(RepairHistoryActivity.this);

                    // 选中开始时间还不执行调用接口，等选择完毕结束时间才可以；
                    //-------------------------------------------------------------------
                    //选择状态重置为【全部】
                    nice_spinner_status_item_repair.post(new Runnable() {
                        @Override
                        public void run() {
                            //重置为：请选择客户状态
                            nice_spinner_status_item_repair.setText(getString(R.string.please_choose_state_repair));
                        }
                    });

                    //状态设置
                    status_upLoad = "";
                    //-------------------------------------------------------------------
                    //搜索变为空的
                    et_searchInManageCheckRecord.setText("");
                    //立即调用接口刷新
                    keyWord_upLoad = "";//et_searchInManageCheckRecord.getText().toString().trim();
                    //-------------------------------------------------------------------
                    //开始时间为空值
                    method_spinner_startTime_firstCreate();
                    spinner_startTime_upLoad = "";

                    //-------------------------------------------------------------------
                    //结束时间为空值
                    method_spinner_endTime_firstCreate();
                    spinner_endTime_upLoad = "";
                    //-------------------------------------------------------------------

                    //发起重新 查询条件 要重置为 从第一页查询,必须重置；
                    pagination_upLoad = Parameterkey.pageNum_default_first;

                    if (mDataResources != null && !mDataResources.isEmpty()) {
                        mDataResources.clear();
                    }

                    if (repairHistoryListAdapter != null) {
                        repairHistoryListAdapter.notifyDataSetChanged();
                    }

                    getServerDatas();
                }
            });
        }

        //----------------------------------------------------------------------------------

        //----------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------

        //----------------------------------------------------------------------------------
        //布局的适配器填充，下拉刷新等等；
        recyclerViewInRepairListHistory.setLayoutManager(new MyLinearLayoutManager(this));
        repairHistoryListAdapter = new RepairHistoryListAdapter(R.layout.repairmanagehistoryadapter, mDataResources);
        recyclerViewInRepairListHistory.setAdapter(repairHistoryListAdapter);

        repairHistoryListAdapter.notifyDataSetChanged();

        repairHistoryListAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                RepairManageItemBean repairManageItemBean = (RepairManageItemBean) adapter.getItem(position);

                if (repairManageItemBean != null) {

                    // : 2023-07-13 15:07 跳转到这个客户的详情页面
                    Bundle extra_bundle = new Bundle();

                    //最低程度携带状态
                    extra_bundle.putParcelable(ExtraKey.EXTRA_REPAIR_MANAGE_ITEM_BEAN, repairManageItemBean);
                    extra_bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, ExtraValue.MODIFY_EVALUATE_CUSTOMER_ONITEM_CLICK_FORM_HISTORY);
                    ActivityUtils.startActivity(extra_bundle, RepairDetailActivity.class);

                }
            }
        });

        repairHistoryListAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {

                RepairManageItemBean repairManageItemBean = (RepairManageItemBean) adapter.getItem(position);

                if (repairManageItemBean != null) {

                    switch (view.getId()) {

                        case R.id.textviewcontanthistory: {//拨打电话的能力

                            clickButton_toCallPhone(RepairHistoryActivity.this, repairManageItemBean.getPhone(), CallHistoryBusinessType.BUSINESSTYPE_3.getIndex());

                            break;
                        }

                        default:
                            break;
                    }
                }
            }
        });

        refreshLayoutInRepairManageListHistory.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {

                refreshLayout.getLayout().post(new Runnable() {
                    @Override
                    public void run() {

                        KeyboardUtils.hideSoftInput(RepairHistoryActivity.this);

                        pagination_upLoad = Parameterkey.pageNum_default_first;

                        if (mDataResources != null && !mDataResources.isEmpty()) {
                            mDataResources.clear();
                        }

                        getServerDatas();

                        refreshLayout.finishRefresh();

                    }
                });

            }

            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {

                refreshLayout.getLayout().post(new Runnable() {
                    @Override
                    public void run() {

                        KeyboardUtils.hideSoftInput(RepairHistoryActivity.this);

                        getServerDatas();

                        refreshLayout.finishLoadMore();

                    }
                });
            }
        });

        //分配人员信息，是不是和其他的分配有些不同
//        if (roundButtonAddReapirManageanGroup != null) {
//            roundButtonAddReapirManageanGroup.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
//                @Override
//                public void onDebouncingClick(View v) {
//
//                    // TODO: 2023-07-13 15:52 跳转到人员分配列表页面
//                    //跳转到资产的添加页面
//                    Bundle extra_bundle = new Bundle();
////
////                    //String shopId = assetInSideBean.getShopId();
////
////                    //是添加进来的
////                    extra_bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE,ExtraValue.VALUE_JUMP_FORM_ASSET_ADD);
////
////                    extra_bundle.putString(ExtraKey.EXTRA_ASSETINSIDEBEAN_SHOPID,assetInSideBean.getShopId());
////
////                    //携带服务站的列表过去
////                    extra_bundle.putParcelableArrayList(ExtraKey.EXTRA_ASSETSTATIONINFOLISTFORADDASSET, assetStationInfoListForAddAsset);
////                    //携带资产的归属方
////                    extra_bundle.putParcelableArrayList(ExtraKey.EXTRA_ASSETUNDERBUSINESSINFOLISTOUTSIDE, assetUnderBusinessInfoListOutSide);
////                    //
//                    ActivityUtils.startActivity(extra_bundle, LeadManagerGroupActivity.class);
//
//                }
//            });
//        }


    }

//    private void method_spinnser_type_repair() {
//
//        //默认原始的是【请选择】接口请求完毕，默认填充第一个：目的是：有一个默认的文字的
//        nice_spinner_type_repair_history.setText(StringUtils.getString(R.string.please_choose_cartype));
//
//        //设置选中文字？
////        nice_spinner_cartype.setTextColor(ColorUtils.getColor(R.color.white));
//
//        //仅仅有点击事件
//        nice_spinner_type_repair_history.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
//            @Override
//            public void onDebouncingClick(View v) {
//
//                //类型是否是动态的？
//                if (dataLisRepairType != null && !dataLisRepairType.isEmpty()) {
//
//                    //添加类别
//                    method_type_repair_fragmentDialog();
//
//                } else {
//
//                    // TODO: 2023-07-13 17:51 是否从接口获取 ；
//
//                    // method_carType_fragmentDialog();
//
//                }
//
//            }
//
//        });
//
//    }


//    private void method_spinnser_formWhere() {
//
//        //默认原始的是【请选择】接口请求完毕，默认填充第一个：目的是：有一个默认的文字的
//        nice_spinner_formWhere.setText(StringUtils.getString(R.string.please_choose_formwhere));
//
//        //设置选中文字？
////        nice_spinner_cartype.setTextColor(ColorUtils.getColor(R.color.white));
//
//        //仅仅有点击事件
//        nice_spinner_formWhere.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
//            @Override
//            public void onDebouncingClick(View v) {
//
//                //类型是否是动态的？
//                if (dataListFromWhere != null && !dataListFromWhere.isEmpty()) {
//
//                    //添加类别
//                    method_formWhere_fragmentDialog();
//
//                } else {
//
//                    // TODO: 2023-07-13 17:51 是否从接口获取 ；
//
//                }
//
//            }
//        });
//
//    }

//    private void method_spinnser_stateItem() {
//
//        //默认原始的是【请选择】接口请求完毕，默认填充第一个：目的是：有一个默认的文字的
//        nice_spinner_state_item_repair_history.setText(StringUtils.getString(R.string.please_choose_state_assigned));
//
//        //设置选中文字？
////        nice_spinner_cartype.setTextColor(ColorUtils.getColor(R.color.white));
//
//        //仅仅有点击事件
//        nice_spinner_state_item_repair_history.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
//            @Override
//            public void onDebouncingClick(View v) {
//
//                //类型是否是动态的？
//                if (dataListStateItem != null && !dataListStateItem.isEmpty()) {
//
//                    //添加 分配状态
//                    method_state_assigned_fragmentDialog();
//
//                } else {
//
//                    // TODO: 2023-07-13 17:51 是否从接口获取 ；
//
//                }
//
//            }
//
//        });
//
//
//    }


//    //添加分配状态的弹窗；  最右侧的筛选条件
//    private void method_state_assigned_fragmentDialog() {
//
//        NomalPickerDialogFragment nomalPickerDialogFragment = NomalPickerDialogFragment.newInstance(dataListStateItem);
//        nomalPickerDialogFragment.setOnNomalChooseListener(new NomalPickerDialogFragment.OnNomalChooseListener() {
//            @Override
//            public void onNomalChoose(NomalCustomBean nomalCustomBean) {
//
//                // : 2023-03-31 做下拉选择的监听--取出用于上传的 检查方式；
////                dimensionality_upLoad = _itemBeanSelected.getType();
//
//                //----------------------------------------------------------------------
//                //变动spinner的文本描述；
//                nice_spinner_state_item_repair_history.post(new Runnable() {
//                    @Override
//                    public void run() {
//                        nice_spinner_state_item_repair_history.setText(nomalCustomBean.getDictLabel());
//                    }
//                });
//
//                // TODO: 2023-07-14 12:00 选中 分配状态的其他逻辑
//
////                getServerDatas();
//                //涉及到变动的其他逻辑；
//
//                //重新编辑。第一个值内容，为了下次的选中做处理；
//                ArrayList<NomalCustomBean> tempAreaCompanyList = new ArrayList<>();
//                if (dataListStateItem != null && !dataListStateItem.isEmpty()) {
//                    Iterator<NomalCustomBean> iterator = dataListStateItem.iterator();
//                    if (iterator != null) {
//                        while (iterator.hasNext()) {
//                            NomalCustomBean item = iterator.next();
//                            if (item != null) {
//                                if (TextUtils.equals(nomalCustomBean.getDictCode(), item.getDictCode())) {
//                                    tempAreaCompanyList.add(0, item);//放在第一条
//                                } else {
//                                    tempAreaCompanyList.add(item);//顺序存放
//                                }
//                            }
//                        }
//                    }
//                }
//
//                //重新保存json
//                MMKV.defaultMMKV().encode(ConstantSign.MMKV_JSON_NOMAL_CUSTOM_JSON,//
//                        JSON.toJSONString(tempAreaCompanyList));//
//                //----------------------------------------------------------------------
//            }
//        });
//
//        nomalPickerDialogFragment.show(getSupportFragmentManager(), "NomalPickerDialogFragmentRepair");
//
//    }

//    private void method_formWhere_fragmentDialog() {
//
//        FromWhereDialogFragment fromWhereDialogFragment = FromWhereDialogFragment.newInstance(dataListFromWhere);
//        fromWhereDialogFragment.setOnFromWhereChooseListener(new FromWhereDialogFragment.OnFromWhereChooseListener() {
//            @Override
//            public void onFromWhereChoose(LeadFromWhereBean leadFromWhereBean) {
//
//                // : 2023-03-31 做下拉选择的监听--取出用于上传的 检查方式；
////                dimensionality_upLoad = _itemBeanSelected.getType();
//
//                //----------------------------------------------------------------------
//                //变动spinner的文本描述；
//                nice_spinner_formWhere.post(new Runnable() {
//                    @Override
//                    public void run() {
//                        nice_spinner_formWhere.setText(leadFromWhereBean.getDictLabel());
//                    }
//                });
//
////                getServerDatas();
//
//                //涉及到变动的其他逻辑；
//
//                //重新编辑。第一个值内容，为了下次的选中做处理；
//                ArrayList<LeadFromWhereBean> tempAreaCompanyList = new ArrayList<>();
//                if (dataListFromWhere != null && !dataListFromWhere.isEmpty()) {
//                    Iterator<LeadFromWhereBean> iterator = dataListFromWhere.iterator();
//                    if (iterator != null) {
//                        while (iterator.hasNext()) {
//                            LeadFromWhereBean item = iterator.next();
//                            if (item != null) {
//                                if (TextUtils.equals(leadFromWhereBean.getDictType(), item.getDictType())) {
//                                    tempAreaCompanyList.add(0, item);//放在第一条
//                                } else {
//                                    tempAreaCompanyList.add(item);//顺序存放
//                                }
//                            }
//                        }
//                    }
//                }
//
//                //重新保存json
//                MMKV.defaultMMKV().encode(ConstantSign.MMKV_JSON_FROM_WHERE_JSON,//
//                        JSON.toJSONString(tempAreaCompanyList));//
//
//                //----------------------------------------------------------------------
//            }
//        });
//
//        fromWhereDialogFragment.show(getSupportFragmentManager(), "FromWhereDialogFragment");
//
//    }

    //左侧第一个 标签的类型：是维修预约 还是 保养预约
//    private void method_type_repair_fragmentDialog() {
//
//        //汽车的类型 弹窗；
//        NomalPickerDialogFragment nomalPickerDialogFragment = NomalPickerDialogFragment.newInstance(dataLisRepairType);
//        nomalPickerDialogFragment.setOnNomalChooseListener(new NomalPickerDialogFragment.OnNomalChooseListener() {
//            @Override
//            public void onNomalChoose(NomalCustomBean nomalCustomBean) {
//
//                //LogUtils.json(ConstantSign.LOGCAT_NOMAL + "选中的内容是-->", bankBusinessInfo);
////                bank_upLoad = bankBusinessInfo.getDictValue();
////              extracted_clearData();
//
//                //选中之后，更改标题；
//                nice_spinner_type_repair_history.post(new Runnable() {
//                    @Override
//                    public void run() {
//                        // TODO: 2023-07-14 09:05 这里仅仅是临时信息，最终以接口返回为准
//                        nice_spinner_type_repair_history.setText(nomalCustomBean.getDictLabel());
//                    }
//                });
//
////                getServerDatas();
//                //-----------------------------------------------------------------------------------
//                //重新编辑。第一个值内容，为了下次的选中做处理；
//                ArrayList<NomalCustomBean> tempSafetyList = new ArrayList<>();
//                if (dataLisRepairType != null && !dataLisRepairType.isEmpty()) {
//                    Iterator<NomalCustomBean> iterator = dataLisRepairType.iterator();
//                    if (iterator != null) {
//                        while (iterator.hasNext()) {
//                            NomalCustomBean item = iterator.next();
//                            if (item != null) {
//                                if (TextUtils.equals(nomalCustomBean.getDictCode(), item.getDictCode())) {
//                                    tempSafetyList.add(0, item);//放在第一条
//                                } else {
//                                    tempSafetyList.add(item);//顺序存放
//                                }
//                            }
//                        }
//                    }
//                }
//
//                //重新存入json
//                MMKV.defaultMMKV().encode(ConstantSign.MMKV_JSON_NOMAL_CUSTOM_JSON,
//                        JSON.toJSONString(tempSafetyList));
//
//            }
//        });
//
//        nomalPickerDialogFragment.show(getSupportFragmentManager(), "NomalPickerDialogFragmentRepairRight");
//
//    }


    @Override
    protected void gainDatas() {

        //是否有其他需要调用接口的地方；
        //这个接口内就是刷新全部内容
        pagination_upLoad = Parameterkey.pageNum_default_first;//重置

        if (mDataResources != null && !mDataResources.isEmpty()) {
            mDataResources.clear();
        }

        if (repairHistoryListAdapter != null) {
            repairHistoryListAdapter.notifyDataSetChanged();
        }

        if (NetworkUtils.isConnected()) {

            getServerDatas();

        } else {
            //是否有其他的执行逻辑？
            netWorkError();
            setEnableLoadmore(refreshLayoutInRepairManageListHistory, false);
        }

    }

    private void getServerDatas() {

        //这里也可以再次重新取值一次
        keyWord_upLoad = et_searchInManageCheckRecord.getText().toString().trim();

        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());//,
//        map.put(Parameterkey.status, "1");//状态
        map.put(Parameterkey.status, RepairStatusUpLoadType.STATE_HAS_DISPATCH.getIndex());//状态

        map.put(Parameterkey.handleStatus, status_upLoad);//状态  2023-10-21 16:41:16 重新传递的
        map.put(Parameterkey.beginTime, spinner_startTime_upLoad);//2023-10-21 16:41:16 添加按时间段查询的开始时间
        map.put(Parameterkey.endTime, spinner_endTime_upLoad);//2023-10-21 16:41:16 添加按时间段查询的开始时间
        map.put(Parameterkey.searchName, keyWord_upLoad);//搜索关键字 searchName  搜索条件(车牌号及销售顾问)

        map.put(Parameterkey.pagination, pagination_upLoad);//传递的页码
        map.put(Parameterkey.pageSize, Parameterkey.pageSize_default);//,搜索关键字

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETAPPOINTMENTLISTPAGE);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.getAppointmentListPage_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .getAppointmentListPage(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                        MediaType.parse(ApiService.HEADER_JSON)))
                .compose(RepairHistoryActivity.this.bindUntilEvent(ActivityEvent.DESTROY))//
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<RepairManageItemOutSide>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                        methodNotSuccessData(what_method, serverCode, serverMessage);
                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {
                        loadingGone();
                        if (refreshLayoutInRepairManageListHistory != null) {
                            refreshLayoutInRepairManageListHistory.setEnableLoadMore(true);
                        }
                    }
                }).subscribe(new Consumer<RepairManageItemOutSide>() {
                    @Override
                    public void accept(RepairManageItemOutSide repairManageItemOutSide) throws Throwable {

                        if (repairManageItemOutSide != null) {

                            ArrayList<RepairManageItemBean> currentDatas = repairManageItemOutSide.getDataList();

                            if (currentDatas != null && !currentDatas.isEmpty()) {
                                if (mDataResources != null) {
                                    mDataResources.addAll(currentDatas);
                                }
                            }
                        }

                        //这里也不用管是下拉刷新或者上拉加载更多，直接判断是否为空，
                        if (mDataResources != null && mDataResources.isEmpty()) {
                            //同时禁用加载更多；
                            if (refreshLayoutInRepairManageListHistory != null) {
                                refreshLayoutInRepairManageListHistory.setEnableLoadMore(false);
                            }

                            fillNullDataView(StringUtils.getString(R.string.nulldatanow), R.drawable.errorsear);
                        }

                        if (repairHistoryListAdapter != null) {
                            repairHistoryListAdapter.notifyDataSetChanged();
                        }

                        //给分页值
                        pagination_upLoad = repairManageItemOutSide.getNextPagination();

                        //对列表改造：
                        if (pagination_upLoad == Parameterkey.GET_NEXT_PAGINATION) {
                            setFinishLoadMoreWithNoMoreData(refreshLayoutInRepairManageListHistory, true);
                        } else {
                            setEnableLoadmore(refreshLayoutInRepairManageListHistory, true);
                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {

                        //页面报错；

                    }
                });


    }

    @Override
    public void methodNotSuccessData(int what_method, String serverCode, String serverMessage) {
        super.methodNotSuccessData(what_method, serverCode, serverMessage);

        switch (what_method) {

            case ConstantApi.WHAT_GETAPPOINTMENTLISTPAGE: {

                if (mDataResources != null && mDataResources.isEmpty()) {

                    if (refreshLayoutInRepairManageListHistory != null) {
                        refreshLayoutInRepairManageListHistory.setEnableLoadMore(false);
                    }

                    CommUtils.checkCurrently((ErrorActivity) mActivityInstance,//
                            serverCode,//
                            R.drawable.errorsear,//
                            serverMessage,//
                            getString(R.string.nulldatanow));
                }

                break;
            }

            default:
                break;
        }
    }

    @Override
    protected void methodBack() {

        if (ActivityUtils.isActivityAlive(this)) {
            ActivityUtils.finishActivity(this);
        }

    }

    private void method_spinner_endTime_firstCreate() {

        //添加--spinner的默认第一条数据
        if (dataEndTime == null) {
            dataEndTime = new ArrayList<>();
        } else {
            dataEndTime.clear();
        }

        //默认是【年月日】的填充，目的为了点击不崩溃；
        String dateFirst = getString(R.string.repair_choose_end_time);//全部-也即是【清空】的操作，后期再改造；
        //String dateSecond = getString(R.string.managecheckymd);//点击这个 就是勾选年月日
        dataEndTime.add(dateFirst);

        if (nice_spinner_end_date != null) {
            nice_spinner_end_date.attachDataSource(dataEndTime);
        }

    }

    private void method_spinner_startTime_firstCreate() {

        //添加--spinner的默认第一条数据
        if (dataStartTime == null) {
            dataStartTime = new ArrayList<>();
        } else {
            dataStartTime.clear();
        }
        //默认是【年月日】的填充，目的为了点击不崩溃；
        String dateFirst = getString(R.string.repair_choose_start_time);//请选择日期全部-也即是【清空】的操作，后期再改造；
        //String dateSecond = getString(R.string.managecheckymd);//点击这个 就是勾选年月日
        dataStartTime.add(dateFirst);
        //datasDate.add(dateSecond);

        if (nice_spinner_start_date != null) {
            nice_spinner_start_date.attachDataSource(dataStartTime);
        }
    }

    private void method_spinnser_stateItem() {

        //默认原始的是【请选择】接口请求完毕，默认填充第一个：目的是：有一个默认的文字的
        nice_spinner_status_item_repair.setText(StringUtils.getString(R.string.please_choose_state_assigned));
        //设置选中文字？
//       nice_spinner_cartype.setTextColor(ColorUtils.getColor(R.color.white));

        //仅仅有点击事件
        nice_spinner_status_item_repair.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
            @Override
            public void onDebouncingClick(View v) {

                //类型是否是动态的？
                if (dataLisRepairStatusType != null && !dataLisRepairStatusType.isEmpty()) {

                    //添加 分配状态
                    method_state_assigned_fragmentDialog();

                } else {

                    // : 2023-07-13 17:51 是否从接口获取 ；

                }

            }

        });


    }

    //添加分配状态的弹窗；  最右侧的筛选条件
    private void method_state_assigned_fragmentDialog() {

        NomalPickerDialogFragment nomalPickerDialogFragment = NomalPickerDialogFragment.newInstance(getResources().getString(R.string.please_choose_state_assigned),//
                dataLisRepairStatusType,//
                ConstantApi.INDEXFLAG_REPAIR_MAIN_LIST_STATEITEM);//

        nomalPickerDialogFragment.setOnNomalChooseListener(new NomalPickerDialogFragment.OnNomalChooseListener() {
            @Override
            public void onNomalChoose(NomalCustomBean nomalCustomBean) {

                //对重置清空做处理
                if (nomalCustomBean != null) {

                    //分配状态是上传的状态编码
                    status_upLoad = nomalCustomBean.getDictCode();

                    method_clear_datas();

                    //----------------------------------------------------------------------
                    //变动spinner的文本描述；
                    nice_spinner_status_item_repair.post(new Runnable() {
                        @Override
                        public void run() {
                            nice_spinner_status_item_repair.setText(nomalCustomBean.getDictLabel());
                        }
                    });

                    //重新保存json
                    MMKV.defaultMMKV().encode(ConstantSign.MMKV_JSON_NOMAL_CUSTOM_JSON_REPAIR_MANAGE_LIST, JSON.toJSONString(ViewUitls.method_sort(dataLisRepairStatusType, nomalCustomBean)));
                    //----------------------------------------------------------------------

                } else {

                    //清空重置
                    status_upLoad = "";
                    nice_spinner_status_item_repair.post(new Runnable() {
                        @Override
                        public void run() {
                            //重置为：请选择客户状态
                            nice_spinner_status_item_repair.setText(getString(R.string.please_choose_state_repair));
                        }
                    });

                    method_clear_datas();

                }
            }
        });

        nomalPickerDialogFragment.show(getSupportFragmentManager(), "NomalPickerDialogFragmentRepair");

    }

    private void method_clear_datas() {

        pagination_upLoad = Parameterkey.pageNum_default_first;

        //变动之后，要清空数据
        if (mDataResources != null && !mDataResources.isEmpty()) {
            mDataResources.clear();
        }

        if (repairHistoryListAdapter != null) {
            repairHistoryListAdapter.notifyDataSetChanged();
        }

        getServerDatas();

    }

    private void method_SearchSomeThing() {

        //获取搜索的关键字内容,刚开始默认是空值
        keyWord_upLoad = et_searchInManageCheckRecord.getText().toString().trim();
        //发起重新 查询条件 要重置为 从第一页查询,必须重置；
        pagination_upLoad = Parameterkey.pageNum_default_first;

        if (!TextUtils.isEmpty(keyWord_upLoad) && (keyWord_upLoad).length() < 2) {
            //ToastUtils.showShort("最少输入两个字符！");
            CommUtils.checkDialog(mAlertView);
            mAlertView = CommUtils.method_showAlertViewSingleSlowly(RepairHistoryActivity.this, ConstantSign.ALERT_TITLE, StringUtils.getString(R.string.pleaseinputkeywordtwo), true);
            mAlertView.show();
            return;
        }

        //如果发起搜索，要重置 第一页
        pagination_upLoad = Parameterkey.pageNum_default_first;
        if (mDataResources != null && !mDataResources.isEmpty()) {
            mDataResources.clear();
        }

        if (repairHistoryListAdapter != null) {
            repairHistoryListAdapter.notifyDataSetChanged();
        }

        getServerDatas();

        if (TextUtils.isEmpty(et_searchInManageCheckRecord.getText().toString().trim())) {
            ToastUtils.make().setGravity(Gravity.CENTER, 0, 0);
            ToastUtils.showShort(getString(R.string.pleaseinputkeyword));
        }

    }

    //添加 选择日期的时候 变动的下拉框，这里仅仅只有那个选中的时间；
    private void method_spinner_startTime_select() {
        if (nice_spinner_start_date != null) {
            nice_spinner_start_date.attachDataSource(dataStartTime);
        }
    }

    private void method_spinner_endTime_select() {
        if (nice_spinner_end_date != null) {
            nice_spinner_end_date.attachDataSource(dataEndTime);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        if (mDataResources != null && !mDataResources.isEmpty()) {
            mDataResources.clear();
        }

        if (repairHistoryListAdapter != null) {
            repairHistoryListAdapter.notifyDataSetChanged();
            repairHistoryListAdapter = null;
        }

        if (mDataResources != null) {
            mDataResources = null;
        }

        if (dataStartTime != null && !dataStartTime.isEmpty()) {
            dataStartTime.clear();
            dataStartTime = null;
        }

        if (dataEndTime != null && !dataEndTime.isEmpty()) {
            dataEndTime.clear();
            dataEndTime = null;
        }

    }
}